{extend name="common/common" /}
{block name="style"}
<style media="screen">
	.curForm .el-input__inner{
		width: 350px;
	}
</style>
{/block}
{block name="content"}
<el-col :lg="12">
<div class="ibox-title">
    <h5>网站设置</h5>
</div>
<div class="ibox-content">
	<el-form
		label-width="100px" :model="form" inline="true"
		:rules="rules" ref="form" class="curForm">
		<el-form-item label="网站域名" prop="DNSname">
			<el-input v-model="form.DNSname" placeholder="请输入网站域名"></el-input>
		</el-form-item><br>
		<el-form-item label="系统名称" prop="title">
			<el-input v-model="form.title" placeholder="请输入系统名称"></el-input>
		</el-form-item><br>
		<el-form-item label="系统版权" prop="copyright">
			<el-input v-model="form.copyright" placeholder="请输入系统版权"></el-input>
		</el-form-item><br>
		<el-form-item label="网站logo" prop="logo">
			<el-tooltip open-delay="500" content="220*60 px" placement="bottom-start">
			<el-input class="logoinput" v-model="form.logo" @focus="upload_logo" placeholder="上传网站logo" readonly></el-input>
			</el-tooltip>
		</el-form-item><br>
		<el-form-item label="迷你logo" prop="mini_logo">
			<el-tooltip open-delay="500" content="70*60 px" placement="bottom-start">
			<el-input v-model="form.mini_logo" @focus="upload_mini_logo" placeholder="上传迷你logo" readonly></el-input>
			</el-tooltip>
		</el-form-item><br>
		<el-form-item label="附件类型" prop="ext">
			<el-tooltip open-delay="500" content="用 '-' 间隔" placement="bottom-start">
			<el-input v-model="form.ext" placeholder="请输入附件类型"></el-input>
			</el-tooltip>
		</el-form-item><br>
		<el-form-item label="上传限制" prop="max_size_of_upload">
			<el-tooltip open-delay="500" content="单位:Mb" placement="bottom-start">
			<el-input v-model="form.max_size_of_upload" placeholder="请输入上传限制"></el-input>
			</el-tooltip>
		</el-form-item><br>
		<el-form-item label="日志时限" prop="log_expire">
			<el-tooltip open-delay="500" content="操作日志保留时间,单位:天" placement="bottom-start">
			<el-input v-model="form.log_expire" placeholder="请输入上传限制"></el-input>
			</el-tooltip>
		</el-form-item><br>
		<el-form-item label="Debug" prop="app_debug">
			<el-radio-group v-model="form.app_debug" size="small">
				<el-radio-button :label="true">开</el-radio-button>
				<el-radio-button :label="false">关</el-radio-button>
    		</el-radio-group>
		</el-form-item>
		<el-form-item label="Trace" prop="app_trace">
			<el-radio-group v-model="form.app_trace" size="small">
				<el-radio-button :label="true">开</el-radio-button>
				<el-radio-button :label="false">关</el-radio-button>
    		</el-radio-group>
		</el-form-item><br>
		<el-form-item label=" ">
			<el-button type="primary" plain @click="subForm('form')">提交</el-button>
		</el-form-item>
	</el-form>
</div>
</el-col>
{/block}

{block name="script"}
<script type="text/javascript">
var main = new Vue({
	el:"#main",
	data() {
		return {
			loading:false,
			form:{
				DNSname:"{$Webset.DNSname|default=''}",
				title:"{$Webset.title|default=''}",
				copyright:"{$Webset.copyright|default=''}",
				logo:"{$Webset.logo|default=''}",
				mini_logo:"{$Webset.mini_logo|default=''}",
				ext:"{$Webset.ext|default=''}",
				max_size_of_upload:"{$Webset.max_size_of_upload|default=''}",
				log_expire:"{$Webset.log_expire|default=5}",
				app_debug:{$Webset.app_debug|default=''},
				app_trace:{$Webset.app_trace|default=''}
			},
			rules:{
				node_name:[{required:true,message:'请输入角色名称',trigger:['blur','change']}],
			}
		}
	},
	methods:{
		subForm(form) {
			this.$refs[form].validate((valid) => {
				if (valid) {
					var param = this.form;
					$.post("./subForm",param,function(res){
						if(res.code == 1){
							main.$notify({
								title: '成功',
								type:'success',
								message: res.msg
							});
						}else{
							main.$notify.error({
								title: '错误',
								message: res.msg
							});
						}
					})
				}
        	});
		},
		upload_logo() {
			uploadAlert.is_show = true;
			uploadAlert.upData = {
				'targetpath':'logo/logo'
			}
			this.call_bac = function (res){
				this.form.logo = res.data.path;
			}
		},
		upload_mini_logo() {
			uploadAlert.is_show = true;
			uploadAlert.upData = {
				'targetpath':'logo/mini_logo'
			}
			this.call_bac = function (res){
				this.form.mini_logo = res.data.path;
			}
		},
		upSuccess(res,file) {
			if(res.code == 1){
				this.$notify({
					title:'成功',
					type:"success",
					message:res.msg
				});
				this.call_bac(res)
			}else{
				this.$notify.error({
					title:'错误',
					message:res.msg
				});
			}
		}
	}
})
</script>
{/block}
